<?php
		/*$mPDF1 = Yii::app()->ePdf->mpdf();
 
        # You can easily override default constructor's params
        */$mPDF1 = Yii::app()->ePdf->mpdf('c','A4','','',7,7,40,40,15,5);
 
        # render (full page)
        //$mPDF1->WriteHTML($this->render('viewPDF', array(), true));
 
        # Load a stylesheet
        $stylesheet = file_get_contents(Yii::getPathOfAlias('webroot.css') . '/pdf.css');
        $mPDF1->WriteHTML($stylesheet, 1);
 
        # renderPartial (only 'view' of current controller)
		
		//--------------------------------------------------------------------------------------------------------
		
		//foreach($model1 as $mdl1){
			$PO_id = $modelHeader->purchase_no;
			$PO_date = $modelHeader->datePO;
			$PO_cur= $modelHeader->quo_no->currency;
			$PO_eta=$modelHeader->eta;
			$PO_terms= $modelHeader->terms;
			$PO_payment_term= $modelHeader->payment_term;
			$PO_freight= $modelHeader->freight;
			$PO_special_instruction= $modelHeader->special_instruction;
			$PO_reff=$modelHeader->reff;
			$PO_attention=$modelHeader->attention;

			$PO_reff=$modelHeader->quo_no->reff;

			$PO_vendor=$modelHeader->vendorID->vendor;
			$PO_phone=$modelHeader->vendorID->phone;
			$PO_fax=$modelHeader->vendorID->fax;
			$PO_address=$modelHeader->vendorID->address;
			$PO_email=$modelHeader->vendorID->email;
		//}
				$currency='  ( $ )';
				$tempCurr=FormatingNumber::currency($PO_cur);
				if($PO_cur=="IDR"){
					$currency='  ( Rp )';
				}
		
		$pdf="
		
<style>
.test {
	border:0.1mm solid #220044; 
}
</style>
			
<!--mpdf
<htmlpageheader name='myHTMLHeader1'>
<table class='headerPdf' width='100%'>
<tr>
	<td rowspan='6'><img src='images/bra_int.jpg' height='100' width='150'></td>
	<td align='right' style='font-family: Arial;vertical-align:bottom ;font-size:18pt;'><b>PT. BRALINK INTERTRADE</b></td> 
</tr>
<tr> <td align='right'>JL. Paso Raya No.20, Kav POLRI</td></tr>
<tr> <td align='right'>Jagakarsa - Jakarta Selatan 12620</td></tr>
<tr> <td align='right'>Indonesia</td></tr>
<tr> <td align='right'>Tlp.62-21 8661 5577</td></tr>
<tr> <td align='right'>Fax.62-21 8661 5588</td></tr>
</table>
</htmlpageheader>

<htmlpagefooter name='myHTMLFooter'>
<table style='font-size: 8pt;' width=100%>
	<tr>
		<td>
		<center>
			<b>PT. Bralink Intertrade</b> <br>
			jl. Raya Paso No.20,Jagakarsa, Jakarta Selatan - Indonesia 12620 <br>
			Phone: +62-21 788 33 279, +62-21 788 40 659, Fax: +62-21 788 30 341<br>
			Website : www.ledlight.co.id
		</center>
	</tr>
</table>
</htmlpagefooter>
mpdf-->


<!-- set the headers/footers - they will occur from here on in the document -->
<!--mpdf
<sethtmlpageheader name='myHTMLHeader1' page='O' value='on' show-this-page='1' />
<sethtmlpagefooter name='myHTMLFooter' page='O' value='on' show-this-page='1' />
mpdf-->

<div class='titlePO'>
PURCHASE ORDER<br>
</div>


<div style='border:.8mm solid #000; padding:1em 1em 0;'>
	<table class='tableView' width='100%'>
		<tr class='rowView'>
			<td  bgcolor='#66CC99' colspan='8'>
			&nbsp;
			</td>
		</tr>
		<tr>
			<td id='customer' class='columnView' colspan='4'>
				To : 
				<table class='customerName' width='100%'>
					<tr>
						<td><h4>".$PO_vendor."</h4></td>
					</tr>
					<tr>
						<td>".$PO_address."</td>
					</tr>
				</table>
				
				<table class='customerDetail' width='100%'>
					<tr>
						<td>Email</td><td>: ".$PO_email."</td>
					</tr>
					<tr>
						<td>Telp/Fax</td><td>: ".$PO_phone." / ".$PO_fax."</td>
					</tr>
					<tr>
						<td>Attn </td><td>: ".$PO_reff."</td>
					</tr>
					<tr>
						<td>REF</td><td>: ".$PO_attention."</td>
					</tr>
				</table>
			</td>
			<td  class='columnView' colspan='4'>
				From :
				<table width='280' class='bralink'>
					<tr>
						<td><h4>PT.BRALINK INTERTRADE</h4></td>
					</tr>
					<tr>
						<td><p>JL. Paso Raya No.20,Kav.PORLI</p>
							<p>Jagakarsa - Jakarta Selatan 12620</p>
							<p>Indonesia</p>
							<br><br>
						</td>
					</tr>
					<tr>
						<td valign='bottom' height='50px'><h4>NPWP: 02.901.188.9-017.000</h4></td>
					</tr>
				</table>
			</td>
		</tr>
		<tr bgcolor='#66CC99'>
			<td id='row2' class='columnView' width='10%'>Date</td>
			<td id='row2' class='columnView' width='30%'>P.O. Number</td>
			<td id='row2' class='columnView' width='5%'>Curr.</td>
			<td id='row2' class='columnView' width='20%' colspan='2'>Terms</td>
			<td id='row2' class='columnView' width='20%' colspan='2'>Paymnet Term</td>
			<td id='row2' class='columnView' width='15%'>Freight</td>
		</tr>
		<tr>
			<td id='u_row2' class='columnView' width='10%'>".$PO_date."</td>
			<td id='row2' class='columnView' width='30%'>".$PO_id."</td>
			<td id='row2' class='columnView' width='5%'>".$PO_cur."</td>
			<td id='row2' class='columnView' width='20%' colspan='2'>".$PO_terms."</td>
			<td id='row2' class='columnView' width='20%' colspan='2'>".$PO_payment_term."</td>
			<td id='row2' class='columnView' width='15%'>".$PO_freight."</td>
		</tr>
		<tr bgcolor='#66CC99'>
			<td id='row2' class='columnView' width='10%'>Line<br>Item</td>
			<td id='row2' class='columnView' width='35%' colspan='2'>Item</td>
			<td id='row2' class='columnView' width='10%'>PN</td>
			<td id='row2' class='columnView' width='10%'>Qty</td>
			<td id='row2' class='columnView' width='10%'>UOM</td>
			<td id='row2' class='columnView' width='10%'>Unit".$currency."</td>
			<td id='row2' class='columnView' width='15%'>Total".$currency."</td>
		</tr>
		";
	
		$x=1;
		$tempSubTotal=0;
		foreach($modelDetail as $mdl2){
		$pdf.="<tr>
				<td id='u_row2' class='columnView' style='border-bottom:none; border-top:none;' width='10%'>".$x."</td>
				<td colspan='2' id='u_row2' class='columnView' style='border-bottom:none; border-top:none;' width='35%'>".$mdl2->products->brands."</td>
				<td id='u_row2' class='columnView' style='border-bottom:none; border-top:none;' width='10%'>".$mdl2->products->product_pn."</td>
				<td id='u_row2' class='columnView' style='border-bottom:none; border-top:none;' width='10%'>".$mdl2->qty."</td>
				<td id='u_row2' class='columnView' style='border-bottom:none; border-top:none;' width='10%'>".$mdl2->uom."</td>
				<td id='u_row2' class='columnView' style='border-bottom:none; border-top:none;' width='10%'>".number_format($mdl2->products->unit_sell*$tempCurr,2,'.',',')."</td>
				<td class='columnView' align='right' style='border-bottom:none; border-top:none;' width='15%'>".number_format($mdl2->qty*$mdl2->products->unit_sell*$tempCurr,2,'.',',')."</td>
			   </tr>";
		$x++;
		$tempSubTotal+=($mdl2->qty*$mdl2->products->unit_sell*$tempCurr);
		}
		$pdf.="
		<tr class='rowView'>
			<td class='columnView' colspan='3' style='padding-right:30px;' align='right'><b>ETA</b></td>
			<td class='columnView' colspan='5' style='padding-left:30px;'><b>".$PO_eta." week(s) after po date</b></td>
		</tr>
		<tr class='rowView' style='border-bottom:none;'>
			<td height='25px' class='columnView' colspan='2' align='left'><b><a href=''>Special Instructions :</a></b></td>
			<td id='u_row2' style='border-left:none;border-right:none;' class='columnView' colspan='3'><b>Sub-Total</b></td>
			<td id='u_row2' style='border-left:none;border-right:none;' class='columnView' colspan='2'><b>".$PO_cur."</b></td>
			<td id='u_row2' style='border-left:none;border-right:none;' class='columnView'><b>".number_format($tempSubTotal,2,'.',',')."</b></td>
		</tr>
		<tr class='rowView'>
			<td rowspan='6' class='columnView' colspan='2' align='left'>
				<table>
					<tr><td>
						".$PO_special_instruction."
					</td></tr>
				</table>
			</td>
			<td height='25px' id='u_row2' style='border-left:none;border-right:none;' class='columnView' colspan='3'><b>VAT 10 %</b></td>
			<td id='u_row2' style='border-left:none;border-right:none;' class='columnView' colspan='2'><b>".$PO_cur."</b></td>
			<td id='u_row2' style='border-left:none;border-right:none;' class='columnView'>&nbsp;</td>
		</tr>
		<tr class='rowView'>
			<td height='25px' id='u_row2' style='border-left:none;border-right:none;' class='columnView' colspan='3'><b>Total</b></td>
			<td id='u_row2' style='border-left:none;border-right:none;' class='columnView' colspan='2'><b>".$PO_cur."</b></td>
			<td id='u_row2' style='border-left:none;border-right:none;' class='columnView'><b>".number_format(($tempSubTotal+$tempSubTotal*0.1),2,'.',',')."</b></td>
		</tr>
		<tr class='rowView' style='border-bottom:none;'>
			<td id='u_row2'  class='columnView' colspan='6' style='border-bottom:none;' align='left'><a href=''>In Words:</a></td>
		</tr>
		<tr class='rowView' style='border-top:none;'>
			<td id='u_row2'  class='columnView' colspan='6' style='border-top:none; color: #393;'><h5><b>".NumberText::makewords(($tempSubTotal+$tempSubTotal*0.1),$PO_cur)."</b></h5></td>
		</tr>
		
		<tr class='rowView'>
			<td colspan='6'>
				<table id='sign' style='margin-bottom:-3px; margin-right:-9px;'>
					<tr bgcolor='#66CC99'>
						<td style='height:30px;' id='u_row2' class='columnView'>Released by:</td>
						<td id='u_row2' class='columnView'>Authorized by:</td>
						<td id='u_row2' class='columnView'>Client Acceptance:</td>
					</tr>
					<tr>
						<td id='row3' class='columnView'>Released by:</td>
						<td id='row3' class='columnView'>Authorized by:</td>
						<td id='row3' class='columnView'>Client Acceptance:</td>
					</tr>
					<tr>
						<td width='34%' id='u_row3' class='columnView'>Ridha</td>
						<td width='33%' id='u_row3' class='columnView'>Wahyu Jatmiko</td>
						<td width='33%' id='u_row3' class='columnView'>nn</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr class='rowView'>
			<td id='u_row2'  class='columnView' colspan='6'>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>
	</table>
	
	<h6 style='font-size:9pt;font-family: DejaVuSansCondensed;'>Please send back for &ldquo;PO-ACCEPTANCE&rdquo; soon after receiving This Purchase Order by Fax to (62) (21) 86615588 or email back to sender, encloses with Banking Account Details. Thanks You</h6>
</div>
		
		
		
		";
		
		//--------------------------------------------------------------------------------------------------------
        $mPDF1->WriteHTML($pdf);
 		$mPDF1->AddPage();
        # Renders image
        //$mPDF1->WriteHTML(CHtml::image(Yii::getPathOfAlias('webroot.css') . '/bg.gif' ));
 
        # Outputs ready PDF
		//$mPDF1->SetDisplayMode('fullpage');
        $mPDF1->Output();//Output('testing.pdf','D');
		exit;
?>